import type { Token } from '@/types/data'
import type { LoginData, UserInfo } from '@/types/user'
import request from '@/utils/request'

/**
 * 登录
 */
export const login = (data: LoginData) => {
  return request<Token>({
    method: 'POST',
    url: '/login',
    data: { ...data }
  })
}

// 获取当前用户信息
export const getUserInfo = () => {
  return request<UserInfo>({
    method: 'GET',
    url: '/user'
  })
}

// 获取当前用户信息
export const logout = () => {
  return request({
    method: 'POST',
    url: '/logout'
  })
}
